<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
	<meta name="description" content="">
	<meta name="author" content="">
	<!-- STYLESHEETS --><!--[if lt IE 9]><script src="../../js/flot/excanvas.min.js"></script><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
	<link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css" >
	<link rel="stylesheet" type="text/css"  href="../../css/themes/default.css" id="skin-switcher" >
	<link rel="stylesheet" type="text/css"  href="../../css/responsive.css" >	
	<link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">
	<!-- SELECT2 -->
	<link rel="stylesheet" type="text/css" href="../../js/select2/select2.min.css" />
	<!-- UNIFORM -->
	<link rel="stylesheet" type="text/css" href="../../js/uniform/css/uniform.default.min.css" />
	<!-- datatable -->
    <link rel="stylesheet" href="../../js/datatables/datatable.css">
    <link rel="stylesheet" href="../../js/datepicker/datepicker.css">
	<!-- FONTS 
	<link href='http://fonts.useso.com/css?family=Open+Sans:300,400,600,700' rel='stylesheet' type='text/css'>
-->
</head>
<body>
	<header class="navbar clearfix" id="header">
	</header>
	
	<!-- PAGE -->
	<section id="page">
				<!-- SIDEBAR -->
				<div id="sidebar" class="sidebar">
					<div class="sidebar-menu nav-collapse">
						
						<!-- SIDEBAR MENU -->
						<ul>							
							
							
						</ul>
						<!-- /SIDEBAR MENU -->
					</div>

				</div>
				<!-- /SIDEBAR -->
		<div id="main-content">
			<div class="modal fade" id="show_reply" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								<h4 class="modal-title">查看回复内容</h4>
							</div>
							<div class="modal-body">
								<div class="form-group">
									<label class="control-label col-md-3" style="line-height:34px;">回复内容：</label>
									<div class="col-md-8">
									<!-- <input type="text" class="form-control" name="replycontent"  maxlength="20" readonly="readonly"/> -->
									<textarea class="form-control" name="replycontent" cols="50"  rows="2" style="resize:none"  maxlength="200" readonly="readonly"></textarea>
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-3" style="line-height:34px;">回复人：</label>
									<div class="col-md-8">
										<input type="text" class="form-control" name="replyby"  maxlength="20" readonly="readonly"/>
										
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-3" style="line-height:34px;">回复时间：</label>
									<div class="col-md-8">
										<input type="text" class="form-control" name="replytime"  maxlength="20" readonly="readonly">
									</div>
								</div>
							</div>
							
							<div class="modal-footer">
								<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
							</div>
						</div>
					</div>
			</div>
			<div class="modal fade" id="reply-comment" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								<h4 class="modal-title">评论回复</h4>
							</div>
							<div class="modal-body">
								<div class="form-group">
									<label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>用户评论：</label>
									
									<div class="col-md-8">
										<input name = "commentId" style="display: none">
										<textarea class="form-control" name="user-comment" cols="50"  rows="2" style="resize:none" readonly="readonly" maxlength="200"></textarea>
									</div>
								</div>
							</div>
							<div class="modal-body">
								<div class="form-group">
									<label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>果妈回复：</label>
									<div class="col-md-8">
										<textarea class="form-control" name="reply-content" cols="50"  rows="2" style="resize:none" placeholder="请输入回复内容" maxlength="200"></textarea>
									</div>
								</div>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
								<button type="button" class="btn btn-primary bt-reply-save">保存</button>
							</div>
						</div>
					</div>
				</div>
			<div class="modal fade" id="box-config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								<h4 class="modal-title">商品评论审批</h4>
							</div>
							<div class="modal-body">
								<div class="form-group">
									<label class="control-label col-md-3" style="line-height:34px;"><span class="required">*</span>审批备注：</label>
									<div class="col-md-8">
										<textarea class="form-control" name="remark" cols="50"  rows="2" style="resize:none" placeholder="请输入备注" maxlength="200"></textarea>
										<input type="hidden" name="id" />
										<input type="hidden" name="status" />
									</div>
								</div>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
								<button type="button" class="btn btn-primary bt-save">保存</button>
							</div>
						</div>
					</div>
				</div>
			<div class="container">
				<div class="row">
					<div id="content" class="col-lg-12">
						<!-- PAGE HEADER-->
						<div class="row">
							<div class="col-sm-12">
								<div class="page-header">
									<!-- STYLER -->
									
									<!-- /STYLER -->
									<!-- BREADCRUMBS -->
									<ul class="breadcrumb">
										<li>
											<i class="fa fa-home"></i>
											<a href="index.html">首页</a>
										</li>
										<li>
											<a href="#">营销管理</a>
										</li>
										<li>优惠劵</li>
									</ul>
									<!-- /BREADCRUMBS -->
									
								</div>
							</div>
						</div>
						<!-- /PAGE HEADER -->
						<!-- FORMS QUERY-->
						<div class="row">
							<div class="col-md-12">
								<div class="row">
									<div class="col-md-12">
										<div class="box border primary">
											<div class="box-title">
												<h4><i class="fa fa-bars"></i>查询条件</h4>
											</div>
											<div class="box-body big" style="padding:10px;">												
												<form class="form-horizontal" role="form" id="form_Product_Comment">
												  <div class="form-group mrg-bt10">
													<label class="col-sm-1 control-label" style="width: auto">商品名称：</label>
													<div class="col-sm-1">
													  <input type="text" class="form-control" name="q" placeholder="输入关键字">
													</div>
											<!-- 		<label class="col-sm-1 control-label" style="width: auto">用户名：</label>
													<div class="col-sm-2">
													  <input type="text" class="form-control" name="userName" placeholder="输入关键字">
													</div> -->
													<label class="col-sm-1 control-label" for="e1" style="width: 100px">状态：</label>
													<div class="col-sm-1">
															<select id="status_select" class="col-md-12 select2-offscreen" tabindex="-1">
															   <option></option>
															   <option value="Waiting">待审核</option>
															   <option value="Pass">通过</option>
															   <option value="Reject">拒绝</option>
															</select>												
													</div>
													
													<label class="col-sm-1 control-label" style="width: auto">评论日期：</label>
													<div class="col-sm-2" style="display:inline-flex">
													<div class="col-sm-2" style="width:130px;padding-left:0px">
														 <input type="text" name="startDate"  class="form-control bootstrap-datepicker">
													</div>
													<div style="width: 20px">至</div>
														<div class="float-left" style="width:130px">
															 <input type="text" name="endDate" class="form-control bootstrap-datepicker">
														</div>	
													</div>
													<div class="col-sm-1" style="width: 100px;padding:0px">
													  <input type="checkbox" checked="checked" name="isUserComment"><span style='margin-left:10px'>用户评论</span>
													</div>
													<label class="col-sm-1 control-label" for="e1" style="width: 100px">订单编号：</label>
													<div class="col-sm-1">
													  <input type="text" class="form-control" name="orderId" placeholder="订单编号">
													</div>
													<div class="col-sm-1">
									       				<a class="btn btn-primary search">查询</a>
													</div>
												  </div>
												 </form>
											</div>
										</div>
									</div>
								</div>		
						    </div>
						</div>
						<!-- /FORMS QUERY -->
						<div class="row" style="height: 30px;">
								<div class="col-md-12">
									<div class="box ">
										<a href="#"  class="btn btn-success config bt-batch-pass" pstatus="Pass">
											<i class="fa  fa-check"></i> 批量通过
										</a>
										<a href="#"  class="btn btn-danger config bt-batch-nopass" pstatus="Reject">
											<i class="fa  fa-times"></i> 批量拒绝
										</a>
									</div>
								</div>
					    </div>							
					    <div class="row">
								<!-- TABLES -->
								<div class="col-md-12">
									<!-- BOX -->
									<div class="box border primary">
										<div class="box-title">
											<h4><i class="fa fa-table"></i>产品评论数：<span id="total"></span> 条</h4>

										</div>
										<div class="box-body">
											<table id="db_Product_Comment_list" cellpadding="0" cellspacing="0" border="0" class="datatable table table-striped table-bordered table-hover">
												
											</table>
										</div>
									</div>
									<!-- /BOX -->
								</div>
							</div>
							<!-- /TABLES -->
						
						
						<div class="footer-tools">
							<span class="go-top">
								<i class="fa fa-chevron-up"></i> Top
							</span>
						</div>
					</div><!-- /CONTENT-->
				</div>
			</div>
		</div>
	</section>
	<!--/PAGE -->
	<!-- JAVASCRIPTS -->
	<!-- Placed at the end of the document so the pages load faster -->
	<!-- JQUERY -->
	<script src="../../js/jquery/jquery-2.0.3.min.js"></script>
	
	<!-- BOOTSTRAP -->
	<script src="../../bootstrap-dist/js/bootstrap.min.js"></script>
	<!-- BLOCK UI -->
	<script type="text/javascript" src="../../js/jQuery-BlockUI/jquery.blockUI.min.js"></script>
	
	<!-- AUTOSIZE -->
	<script type="text/javascript" src="../../js/autosize/jquery.autosize.min.js"></script>
	<!-- spinner -->
		<script src="../../js/spinner/spin.js"></script>
	<!-- DATA TABLES -->
		<script type="text/javascript" src="../../js/datatables/bootstrap-select.js"></script>
		<script type="text/javascript" src="../../js/datatables/datatable.js"></script>
		<script type="text/javascript" src="../../js/datatables/datatable-bootstrap.js"></script>
		<script type="text/javascript" src="../../js/datatables/datatable-tabletools.js"></script>
		<script type="text/javascript" src="../../js/datatables/fnAddTr.js"></script>

	<!-- INPUT MASK -->
	<script type="text/javascript" src="../../js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>
   	<!--bootbox-->
	<script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>
	<!-- SELECT2 -->
	<script type="text/javascript" src="../../js/select2/select2.min.js"></script>
	<!-- UNIFORM -->
	<script type="text/javascript" src="../../js/uniform/jquery.uniform.min.js"></script>
		<script type="text/javascript" src="../../js/datepicker/datepicker.js"></script>
	<!-- COOKIE -->
	<script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
	<!-- CUSTOM SCRIPT -->
	<script src="../../js/script.js"></script>
	<script src="../../js/common.js"></script>
		<script>		
		var Product_Comment=function(){
	         var  $mainDataTable=null;     
	         //行审批对话框
	         var approveDialog=function(){
	        	$("#db_Product_Comment_list").on("click",".bt-pass,.bt-nopass",function() {
	        		$.clearInput();
					var id = $(this).attr("pid");
					var status = $(this).attr("pstatus");
					$("#box-config").find(".form-group").find("input[name=id]").val(id);
					$("#box-config").find(".form-group").find("input[name=remark]").val("");
					$("#box-config").find(".form-group").find("input[name=status]").val(status);
					$("#box-config").modal("show");
					$(".bt-save").unbind("click").click(approveSubmit);
				});
	        };
	        //行审核操作
	        var approveSubmit=function(){
	        	console.log($("input[name=status]").val());
	        	console.log($("textarea[name=remark]").val());
	          if($("input[name=status]")=="Reject"||$("textarea[name=remark]").val()=="")
	          {
	             $.alert("请输入拒绝原因");
	             return false;
	          }
	          $.ajax({
					type: "post",
					url: App.getContextPath()+"admin/productComment/approveProductComment.do",
					async: true,
					data: {id: $("input[name=id]").val(),remark:$("input[name=remark]").val(),status:$("input[name=status]").val()},
					success: function(result) {
							  $("#box-config").modal("hide");
							  searchProductComment();
							   //页面不刷新，将id 对应的行 的 审批通过及拒绝按钮隐藏
							   /* $("#db_Product_Comment_list tbody tr").each(function(){
							   		if($(this).find(".id").html()==$("input[name=id]").val()){
							   		  $(this).not("a:eq(2)").remove();
							   		  return true;
							   		}
							   }); */
							 }
				   });
	        
	        };
	        
	         var batchApprove=function(){
	           var ids=$.getSelectedList($("#db_Product_Comment_list"));
	           var status=$(this).attr("pstatus");
		        if(ids.length==0)
		        {
		          $.alert("请选择需要操作的记录");
		          return false;
		          
		        }
		        $.ajax({
					type: "post",
					url: App.getContextPath()+"admin/productComment/batchApproveProductComment.do",
					async: true,
					data: {ids: ids.toString(),remark:$("input[name=remark]").val(),status:status},
					success: function(result) {
							  searchProductComment();
							 }
				   });
	        };
	        
	        
	         var searchProductComment=function(){
	         
	          var startDate=$("input[name=startDate]").val();
	          var endDate=$("input[name=endDate]").val();            
	          var url=App.getContextPath()+"admin/productComment/searchProductComment.do?q="+$("input[name=q]").val()+"&isUserComment="+$("[name=isUserComment]").prop("checked")+"&pStatus="+$("#status_select").val()+"&userName="+$("[name=userName]").val();
	            url+="&orderId="+$("[name=orderId]").val()
	            if(startDate!="")
					url+="&startDate="+startDate;
				if(endDate!="")
				   url+="&endDate="+$.dateAdd(endDate);
			       if($mainDataTable){
			           $mainDataTable.api().ajax.url(url).load();	   		
		   		       return;	
			        }
		           var dtSetting = $.dataTableSetting({					
							"ajaxSource" :url,
							"serverSide" : true,
							"bFilter" : false,// 去掉搜索框
							"bLengthChange" : true,// 每页显示数量							
							"sScrollX":"100%",
							"sScrollXInner": "100%",
							"iDisplayLength": 25,
							
							"bSort" : false,					
							"aoColumns" : [  {
							"sTitle" : "<div class='checkbox checkbox-primary'><input type='checkbox' name='checkboxall' id='inlineCheckbox110' class='custom-checkbox' value=''/></div>",
							"render" : function(data, type, row) {							
								var checkBox = "<div class='checkbox checkbox-primary'><input type='checkbox' name='checkbox' id='inlineCheckbox110' class='custom-checkbox' value='"
										+ row.id + "'/></div>";
								if(row.checkStatus=="Pass")
								 return checkBox;
								 return "";
							   },
							"width" : "5%"
							},{
								"mDataProp" : "id",
								"sTitle" : "ID",
								"width" : "5%"				
							}, {
								"mDataProp" : "productName",
								"sTitle" : "商品名称",
								"width" : "10%"								
							}, {
								"mDataProp" : "nickName",
								"sTitle" : "用户昵称",
								"width" : "8%"								
							}	
							 , {
								"mDataProp" : "orderId",
								"sTitle" : "订单编号",
								"width" : "8%"								
							} 	
							, {						
								"sTitle" : "内容",
								"mDataProp" : "content",
								"width" : "12%"								
							}	
							, {							   	
								"sTitle" : "状态 ",	
								"width" : "6%",
								"render":function(data,type,row){
									if(row.checkStatus=="Pass")return "通过";
									if(row.checkStatus=="Waiting")return "待审核";
									if(row.checkStatus=="Reject")return "拒绝";
								}										
							},{
								"sTitle" : "领券",	
								"width" : "6%",
								"render":function(data,type,row){
									if(row.couponDetailId>0)return "是";
									return "否";
								}		
							}						
							, {
								
								"sTitle" : "创建时间",
								"width" : "8%",
								"render":function(data, type, row){
								     return $.getLocalTime(row.createTime);
								}
							}, {
								
								"sTitle" : "审核人",
								"width" : "6%",
								"mDataProp" : "checkBy"
							}, {
								
								"sTitle" : "审核时间",
								"width" : "8%",
								"render":function(data, type, row){
								if(row.checkTime!=null)
								  return $.getLocalTime(row.checkTime);
								  return "";
								}
							}, {
								"sTitle" : "操作",
								"width" : "13%",
								"render":function(data, type, row){
								   var str="";
								   if(row.checkStatus=="Pass")
								   {
								     
							         str+="<a class='btn btn-danger btn-xs btn-width bt-nopass' style='width:60px;margin-bottom:5px;' href='#' pid="+row.id+" pstatus='Reject'><i class='fa  fa-times'></i>拒绝</a>";
								  				       
									   if(row.replyContent == null)
									   {
								         str+="<a class='btn btn-primary btn-xs btn-width bt-noreply' style='width:60px;margin-bottom:5px;margin-left:10px;' href='#' pid="+row.id+" content="+row.content+"><i class='fa  fa-copy'></i>回复</a><br>";
									   }else{
								         str+="<a class='btn btn-warning btn-xs btn-width bt-showreply' style='width:60px;margin-bottom:5px;margin-left:10px;' href='#' pid="+row.id+" replycontent="+row.replyContent+" replyby="+row.replyBy+" replytime ="+row.replyTime+"><i class='fa  fa-arrow-circle-o-up'></i>查看</a><br>";
									   }					       
								   }	
								return str;
								}
							}]
						});
					
				      $mainDataTable = $("#db_Product_Comment_list").dataTable(dtSetting);
	         };
	         var replyComment = function(){
		        	$("#db_Product_Comment_list").on("click",".bt-noreply",function() {
						$("[name=user-comment]").html($(this).attr("content"));
						$("[name=commentId]").val($(this).attr("pid"));
						$("[name=reply-content]").val("");
		        	 $("#reply-comment").modal("show");
		        		
		        	});
		        	replySave();
		        };
		        
		        var replySave = function(){
		        	$(".bt-reply-save").click(function(){
		        		var content= $("[name=reply-content]").val();
		        		var commentId= $("[name=commentId]").val();
		        		if(content ==""){
		        			$.alert("请输入回复内容！");
		        			return false;
		        		}
		        	 $.ajax({
							type: "post",
							url: App.getContextPath()+"admin/productComment/replySave.do",
							async: true,
							data: {id: commentId,replyContent:content},
							success: function(result) {
								 $("#reply-comment").modal("hide");
									  searchProductComment();
									 }
						   });
		        	});
		        }
		        var showreply = function(){
					$("#db_Product_Comment_list").on("click",".bt-showreply",function() {
						$("[name=replycontent]").val($(this).attr("replycontent"));
						$("[name=replyby]").val($(this).attr("replyby"));
						$("[name=replytime]").val($.getLocalTime($(this).attr("replytime")));
		        	 $("#show_reply").modal("show");
		        	});
		        };
	         
	         return {	         
	         init:function(){
	           $.initDate($("#form_Product_Comment"),-30,0);	         
	           $("#status_select").select2({placeholder: "选择状态"});
	           var name=$.getUrlParam("name");
	           if(name!=null)$("[name=q]").val(name);
	          $(".search").click(searchProductComment);	
	            searchProductComment();
	            approveDialog();
	            $(".bt-batch-nopass,.bt-batch-pass").click(batchApprove);     
	            showreply();        
	            replyComment();        
	          }
		    }
	      }();
	      
	      $(function(){
	      	$("#header").load("../head.html");
	        App.init(); //Initialise plugins and elements	        
	      	Product_Comment.init();
	      	
	      });
		</script>
		<!-- /JAVASCRIPTS -->
</body>
</html>